package com.probox.common.entity.domain.customer;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;

import com.probox.common.core.enums.CustomerFundBizTypeEnum;
import com.probox.common.core.enums.CustomerFundStatusEnum;
import com.probox.common.core.utils.money.MoneyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.*;
import com.probox.common.core.annotation.Excel;

/**
 * 客户资金明细对象 customer_fund_detail
 *
 * @author zsy
 * @date 2021-06-18
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("customer_fund_detail")
public class CustomerFundDetail implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 明细ID
     */
    //默认主键自增
    @TableId(value = "DETAIL_UID", type = IdType.AUTO)
    private Long detailUid;

    @Excel(name = "店铺ID")
    private Long platformUid;
    /**
     * 会员信息ID
     */
    @Excel(name = "会员信息ID")
    private Long customerUid;
    /**
     * $column.columnComment
     */
    @Excel(name = "会员信息ID")
    private String bizDesc;
    /**
     * 积分/分润/余额支付/餐卡支付
     */
    @Excel(name = "积分/分润/余额支付")
    private String bizType;
    /**
     * 业务id，订单号/记录id等
     */
    @Excel(name = "业务id，订单号/记录id等")
    private String bizNo;
    /**
     * 订单子项目ID
     */
    @Excel(name = "订单子项目ID")
    private Long itemUid;

    /**
     * 订单号
     */
    @Excel(name = "订单ID")
    private Long orderUid;
    /**
     * 积分/分润金额/余额支付金额/餐卡支付
     */
    @Excel(name = "积分/分润金额/余额支付金额/餐卡支付")
    private Long amount;
    /**
     * $column.columnComment
     */
    @Excel(name = "备注")
    private String remark;
    /**
     * $column.columnComment
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "积分/分润金额/余额支付金额/餐卡支付", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date bizTime;
    /**
     * 明细创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "明细创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 资金状态
     */
    @ApiModelProperty(value = "资金状态")
    @Excel(name = "资金状态")
    private String fundStatus;

    /**
     * 状态(1有效/0无效)
     */
    @Excel(name = "状态(1有效/0无效)")
    private String dataStatus;
    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 由某个用户发起
     */
    private Long fromCustomerUid;

    private Long storeId;

    @TableField(exist = false)
    private String storeName;

    @TableField(exist = false)
    private String startDate;
    @TableField(exist = false)
    private String endDate;

    @TableField(exist = false)
    private String phone;

    @TableField(exist = false)
    private String customerNo;

    @TableField(exist = false)
    private String[] createTimeArr;


    /**
     * 金额处理
     *
     * @return
     */
    public String getAmountStr() {
        if (CustomerFundBizTypeEnum.score.getKey().equals(bizType)) {
            return String.valueOf(amount);
        }
        return MoneyUtils.changeF2B(amount);
    }

    public String getDataStatusStr() {
        if (CustomerFundStatusEnum.valid.getKey().equals(this.dataStatus)) {
            return CustomerFundStatusEnum.valid.getValue();
        }
        if (CustomerFundStatusEnum.invalid.getKey().equals(this.dataStatus)) {
            return CustomerFundStatusEnum.invalid.getValue();
        }
        if (CustomerFundStatusEnum.freeze.getKey().equals(this.dataStatus)) {
            return CustomerFundStatusEnum.freeze.getValue();
        }
        return null;
    }

    private Long createUser;
    private String createName;

    private String deductType;

    private Integer expireHour;

}
